# 安装依赖，pip install kafka-python
from kafka import KafkaProducer

# 1、创建生产者,创建连接
kafkaProducer = KafkaProducer(bootstrap_servers='master:9092')

# 生产数据
kafkaProducer.send('shujia', b'shujia')
# 刷新
kafkaProducer.flush()

# 关闭连接
kafkaProducer.close()
